package com.group525.cloudef.controller.user;


import com.group525.cloudef.Dao.user.LoginDao;
import com.group525.cloudef.common.CommonResult;
import com.group525.cloudef.entity.user.UUser;
import com.group525.cloudef.service.user.UUserService;
import com.group525.cloudef.utils.Log;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.websocket.server.PathParam;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author group525
 * @since 2023-05-23
 */
@RestController
@RequestMapping("/user")
@CrossOrigin
public class UUserController {

    @Resource
    Log log;

    @Resource
    UUserService userService;

    @PostMapping("login")
    public CommonResult<?> login(@RequestBody LoginDao loginDao) {
        log.debug(" 用户信息 ：", loginDao);
        return userService.login(loginDao);
    }

    @PostMapping("saveUser")
    public CommonResult<?> saveUser(@RequestBody UUser user) {
        log.debug(" 用户信息 ：", user);
        if (userService.updateById(user)) {
            return CommonResult.success("保存成功");
        }
        return CommonResult.failed();
    }



}

